package org.mat.ipaas.ucenter.service.api.system;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysDepartPermissionDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 部门权限表
 */
@Api(tags = "部门权限表")
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "sys-depart-permission-rest-api")
public interface SysDepartPermissionRestAPI {

    /**
     * 分页列表查询
     *
     * @param sysDepartPermissionDTO
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "部门权限表-分页列表查询", notes = "部门权限表-分页列表查询")
    @GetMapping(value = "/sys/sysDepartPermission/list")
    MatApiResponse<?> queryPageList(@SpringQueryMap SysDepartPermissionDTO sysDepartPermissionDTO,
                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

    /**
     * 添加
     *
     * @param sysDepartPermissionDTO
     * @return
     */
    @ApiOperation(value = "部门权限表-添加", notes = "部门权限表-添加")
    @PostMapping(value = "/sys/sysDepartPermission/add")
    MatApiResponse<?> add(@RequestBody SysDepartPermissionDTO sysDepartPermissionDTO);

    /**
     * 编辑
     *
     * @param sysDepartPermissionDTO
     * @return
     */
    @ApiOperation(value = "部门权限表-编辑", notes = "部门权限表-编辑")
    @RequestMapping(value = "/sys/sysDepartPermission/edit", method = {RequestMethod.POST})
    MatApiResponse<?> edit(@RequestBody SysDepartPermissionDTO sysDepartPermissionDTO);

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "部门权限表-通过id删除", notes = "部门权限表-通过id删除")
    @DeleteMapping(value = "/sys/sysDepartPermission/delete")
    MatApiResponse<?> delete(@RequestParam(name = "id", required = true) String id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "部门权限表-批量删除", notes = "部门权限表-批量删除")
    @DeleteMapping(value = "/sys/sysDepartPermission/deleteBatch")
    MatApiResponse<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "部门权限表-通过id查询", notes = "部门权限表-通过id查询")
    @GetMapping(value = "/sys/sysDepartPermission/queryById")
    MatApiResponse<SysDepartPermissionDTO> queryById(@RequestParam(name = "id", required = true) String id);

    /**
     * 导出excel
     *
     * @param sysDepartPermissionDTO
     */
    @RequestMapping(value = "/sys/sysDepartPermission/exportXls")
    ModelAndView exportXls(SysDepartPermissionDTO sysDepartPermissionDTO);

    /**
     * 通过excel导入数据
     *
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartPermission/importExcel", method = RequestMethod.POST)
    MatApiResponse<?> importExcel();

    /**
     * 部门管理授权查询数据规则数据
     */
    @GetMapping(value = "/sys/sysDepartPermission/datarule/{permissionId}/{departId}")
    MatApiResponse<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("departId") String departId);

    /**
     * 保存数据规则至部门菜单关联表
     */
    @PostMapping(value = "/sys/sysDepartPermission/datarule")
    MatApiResponse<?> saveDatarule(@RequestBody JSONObject jsonObject);

    /**
     * 查询角色授权
     *
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartPermission/queryDeptRolePermission", method = RequestMethod.GET)
    MatApiResponse<List<String>> queryDeptRolePermission(@RequestParam(name = "roleId", required = true) String roleId);

    /**
     * 保存角色授权
     *
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartPermission/saveDeptRolePermission", method = RequestMethod.POST)
    MatApiResponse<String> saveDeptRolePermission(@RequestBody JSONObject json);

    /**
     * 用户角色授权功能，查询菜单权限树
     *
     * 
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartPermission/queryTreeListForDeptRole", method = RequestMethod.GET)
    MatApiResponse<Map<String, Object>> queryTreeListForDeptRole(@RequestParam(name = "departId", required = true) String departId, @RequestParam HttpServletRequest request);

}
